package com.gsn.poker.asset;

import java.util.HashMap;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver;
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.GsnImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.gsn.engine.gdx.GsnParticleActor;
import com.gsn.engine.gdx.assets.GsnManagerTexture;
import com.gsn.engine.gdx.assets.GsnParticleLoader;
import com.gsn.poker.game.MyPoker;

public class PortalTexture extends GsnManagerTexture {
	public static PortalTexture _instance;

	public static PortalTexture inst() {
		if (_instance == null)
			_instance = new PortalTexture();
		return _instance;
	}

	public PortalTexture() {

		resolutions = new Resolution[1];
		resolutions[0] = new Resolution(240, 320, "240320");

		resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), resolutions);
		manager = new AssetManager(resolver);
	}

	static public final String tag = "Portal Texture";

	// static public List<AtlasRegion> timeCho;

	public AtlasRegion iconGirl;
	public AtlasRegion bgPortal;

	public AtlasRegion helpButton;
	public AtlasRegion helpButtonPress;
	public AtlasRegion registerButton;
	public AtlasRegion registerButtonPress;
	public AtlasRegion inviteButton;
	public AtlasRegion inviteButtonPress;
	public AtlasRegion loginButton;
	public AtlasRegion loginButtonPress;
	public AtlasRegion checkButton;
	public AtlasRegion checkButtonPress;
	public AtlasRegion settingButton;
	public AtlasRegion settingButtonPress;
	public AtlasRegion quitButton;
	public AtlasRegion quitButtonPress;
	public AtlasRegion putButton;
	public AtlasRegion putButtonPress;
	public AtlasRegion shopButton;
	public AtlasRegion shopButtonPress;
	public AtlasRegion closeButton;
	public AtlasRegion closeButtonPress;
	public AtlasRegion agreeButton;
	public AtlasRegion agreeButtonPress;
	public AtlasRegion cancelButton;
	public AtlasRegion cancelButtonPress;
	public AtlasRegion soundButton;
	public AtlasRegion soundButtonPress;
	public AtlasRegion vibrateButton;
	public AtlasRegion vibrateButtonPress;
	public AtlasRegion caroButton;
	public AtlasRegion caroButtonPress;
	public AtlasRegion pokerButton;
	public AtlasRegion pokerButtonPress;
	public AtlasRegion talaButton;
	public AtlasRegion talaButtonPress;
	public AtlasRegion tienlenButton;
	public AtlasRegion tienlenButtonPress;
	public AtlasRegion iconChannel0;
	public AtlasRegion iconChannel0Press;
	public AtlasRegion iconChannel0Disable;
	public AtlasRegion iconChannel1;
	public AtlasRegion iconChannel1Press;
	public AtlasRegion iconChannel1Disable;
	public AtlasRegion iconChannel2;
	public AtlasRegion iconChannel2Press;
	public AtlasRegion iconChannel2Disable;
	public AtlasRegion iconChannel3;
	public AtlasRegion iconChannel3Press;
	public AtlasRegion iconChannel3Disable;
	public AtlasRegion iconChannel4;
	public AtlasRegion iconChannel4Press;
	public AtlasRegion iconChannel4Disable;
	public AtlasRegion iconChannel5;
	public AtlasRegion iconChannel5Press;
	public AtlasRegion iconChannel5Disable;
	public AtlasRegion changeGoldButton;
	public AtlasRegion changeGoldPress;
	public AtlasRegion chooseRoomButton;
	public AtlasRegion chooseRoomButtonPress;
	public AtlasRegion maskIndexButton;
	public AtlasRegion maskIndexButtonPress;
	public AtlasRegion maskBetButton;
	public AtlasRegion maskBetButtonPress;
	public AtlasRegion maskNumButton;
	public AtlasRegion maskNumButtonPress;
	public AtlasRegion iconMake;
	public AtlasRegion iconMakePress;
	public AtlasRegion iconPlay;
	public AtlasRegion iconPlayPress;
	public AtlasRegion iconUpdate;
	public AtlasRegion iconUpdatePress;
	public AtlasRegion iconDropDialog;
	public AtlasRegion iconDropDialogPress;
	public AtlasRegion iconReceiveGift;
	public AtlasRegion iconReceiveGiftPress;

	public AtlasRegion iconCuComming;
	public AtlasRegion textBoxGrey;
	public AtlasRegion highLight;
	public AtlasRegion xitoLogo;
	public AtlasRegion title;
	public AtlasRegion logo;
	public AtlasRegion iconGoldSmall;
	public AtlasRegion iconGoldBig;
	public AtlasRegion iconXuBig;
	public AtlasRegion iconXuSmall;
	public AtlasRegion bgAvatar;
	public AtlasRegion iconLine;
	public AtlasRegion bgChooseChannel;
	public AtlasRegion bgQuickShop;
	public AtlasRegion bgDialog;
	public AtlasRegion iconComming;
	public AtlasRegion bgDarkDialog;
	public AtlasRegion bgSetting;
	public AtlasRegion sortDown;
	public AtlasRegion sortUp;
	public AtlasRegion bgChooseRoom;
	public AtlasRegion textBoxWhite;
	public AtlasRegion bgChooseLeaf;
	public AtlasRegion iconMaskDrop;
	public AtlasRegion iconMaskDropPress;
	public AtlasRegion gift1;
	public AtlasRegion gift234;
	public AtlasRegion gift5;
	public AtlasRegion gift1Disable;
	public AtlasRegion gift234Disable;
	public AtlasRegion gift5Disable;
	public AtlasRegion goldGift;
	public AtlasRegion goldGiftDisable;
	public AtlasRegion iconDeco;
	public AtlasRegion bgGift;

	public AtlasRegion iconRepair;
	public Skin skin;

	public ParticleEffect clickEff;
	public ParticleEffect jackpotEff;
	public boolean assigned = false;

	/*
	 * public void assignContent(PokerTexture obj) { if (!onceAssign) return;
	 * 
	 * clickEff = GsnParticleActor.loadParticleEffect(resolver,
	 * "poker/particle/click.p");
	 * 
	 * TextureAtlas atlas = manager.get("poker/content/pack",
	 * TextureAtlas.class); fontMedium = manager.get("poker/font/medium.fnt",
	 * BitmapFont.class); fontLarge = manager.get("poker/font/large.fnt",
	 * BitmapFont.class); // board = atlas.findRegion("BG1");
	 * 
	 * Field[] fields = PokerTexture.class.getFields(); for (int i = 0; i <
	 * fields.length; i++) { Field f = fields[i]; if
	 * (Modifier.isPublic(f.getModifiers()) &&
	 * Modifier.isStatic(f.getModifiers())) { try { if (f.get(obj) != null)
	 * continue; if (f.getType() == AtlasRegion.class) { AtlasRegion region =
	 * atlas.findRegion(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "region = null voi : " + f.getName()); } }
	 * 
	 * if (f.getType() == List.class) { List<AtlasRegion> region =
	 * atlas.findRegions(f.getName()); f.set(obj, region); if (region == null) {
	 * Gdx.app.log(tag, "List<region> = null voi : " + f.getName()); } } } catch
	 * (Exception e) { e.printStackTrace(); } } } onceAssign = false; }
	 */
	@Override
	public void assignTask() {

		clickEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/click.p");
		jackpotEff = GsnParticleActor.loadParticleEffect(resolver, "poker/particle/jackpot.p");
		TextureAtlas atlas = manager.get("portal/pack", TextureAtlas.class);
		iconGirl = atlas.findRegion("iconGirl");
		bgPortal = atlas.findRegion("bgPortal");
		title = atlas.findRegion("iconTitle");
		logo = atlas.findRegion("iconLogo");
		bgAvatar = atlas.findRegion("iconAvatar");
		iconGoldSmall = atlas.findRegion("iconGold");
		iconXuSmall = atlas.findRegion("iconXu");
		iconGoldBig = atlas.findRegion("iconGoldBig");
		iconXuBig = atlas.findRegion("iconXuBig");

		textBoxGrey = atlas.findRegion("textBoxGrey");
		iconLine = atlas.findRegion("iconLine");
		bgQuickShop = atlas.findRegion("bgQuickShop");
		bgChooseChannel = atlas.findRegion("bgChooseChannel");
		bgDarkDialog = atlas.findRegion("bgDarkDialog");
		bgDialog = atlas.findRegion("bgDialog");
		iconComming = atlas.findRegion("iconComming");
		bgSetting = atlas.findRegion("bgSetting");
		sortDown = atlas.findRegion("iconSortDown");
		sortUp = atlas.findRegion("iconSortUp");
		bgChooseRoom = atlas.findRegion("bgChooseRoom");
		textBoxWhite = atlas.findRegion("textBoxWhite");
		bgChooseLeaf = atlas.findRegion("bgChooseLeaf");

		helpButton = atlas.findRegion("iconHelp");
		helpButtonPress = atlas.findRegion("iconHelpPress");
		registerButton = atlas.findRegion("iconRegister");
		registerButtonPress = atlas.findRegion("iconRegisterPress");
		loginButton = atlas.findRegion("iconLogin");
		loginButtonPress = atlas.findRegion("iconLoginPress");
		inviteButton = atlas.findRegion("iconInvite");
		inviteButtonPress = atlas.findRegion("iconInvitePress");
		checkButton = atlas.findRegion("iconCheckOff");
		checkButtonPress = atlas.findRegion("iconCheckOn");
		settingButton = atlas.findRegion("iconSetting");
		settingButtonPress = atlas.findRegion("iconSettingPress");
		quitButton = atlas.findRegion("iconQuit");
		quitButtonPress = atlas.findRegion("iconQuitPress");
		putButton = atlas.findRegion("iconPut");
		putButtonPress = atlas.findRegion("iconPutPress");
		shopButton = atlas.findRegion("iconShop");
		shopButtonPress = atlas.findRegion("iconShopPress");
		closeButton = atlas.findRegion("iconClose");
		closeButtonPress = atlas.findRegion("iconClosePress");
		agreeButton = atlas.findRegion("iconAgree");
		agreeButtonPress = atlas.findRegion("iconAgreePress");
		cancelButton = atlas.findRegion("iconCancel");
		cancelButtonPress = atlas.findRegion("iconCancelPress");
		soundButton = atlas.findRegion("iconSound");
		soundButtonPress = atlas.findRegion("iconSoundOff");
		vibrateButton = atlas.findRegion("iconVibrate");
		vibrateButtonPress = atlas.findRegion("iconVibrateOff");
		tienlenButton = atlas.findRegion("iconGametienlen");
		tienlenButtonPress = atlas.findRegion("iconGametienlenPress");
		pokerButton = atlas.findRegion("iconGamePoker");
		pokerButtonPress = atlas.findRegion("iconGamePokerPress");
		tienlenButton = atlas.findRegion("iconGameTienlen");
		tienlenButtonPress = atlas.findRegion("iconGameTienlenPress");
		talaButton = atlas.findRegion("iconGameTala");
		talaButtonPress = atlas.findRegion("iconGameTalaPress");
		caroButton = atlas.findRegion("iconGameCaro");
		caroButtonPress = atlas.findRegion("iconGameCaroPress");
		changeGoldButton = atlas.findRegion("iconChangeGold");
		changeGoldPress = atlas.findRegion("iconChangeGoldPress");
		chooseRoomButton = atlas.findRegion("iconOneRoom");
		chooseRoomButtonPress = atlas.findRegion("iconOneRoomPress");
		maskBetButton = atlas.findRegion("iconMaskBet");
		maskBetButtonPress = atlas.findRegion("iconMaskBetPress");
		maskIndexButton = atlas.findRegion("iconMaskIndex");
		maskIndexButtonPress = atlas.findRegion("iconMaskIndexPress");
		maskNumButton = atlas.findRegion("iconMaskNum");
		maskNumButtonPress = atlas.findRegion("iconMaskNumPress");
		iconMake = atlas.findRegion("iconMake");
		iconMakePress = atlas.findRegion("iconMakePress");
		iconPlay = atlas.findRegion("iconPlay");
		iconPlayPress = atlas.findRegion("iconPlayPress");
		iconUpdate = atlas.findRegion("iconRefresh");
		iconUpdatePress = atlas.findRegion("iconRefreshPress");
		iconDropDialog = atlas.findRegion("iconDropDialog");
		iconDropDialogPress = atlas.findRegion("iconDropDialogPress");
		iconMaskDrop = atlas.findRegion("iconDrop");
		iconMaskDropPress = atlas.findRegion("iconDropPress");

		iconChannel0 = atlas.findRegion("iconChannel0");
		iconChannel0Press = atlas.findRegion("iconChannel0Press");
		iconChannel0Disable = atlas.findRegion("iconChannel0Disable");
		iconChannel1 = atlas.findRegion("iconChannel1");
		iconChannel1Press = atlas.findRegion("iconChannel1Press");
		iconChannel1Disable = atlas.findRegion("iconChannel1Disable");
		iconChannel2 = atlas.findRegion("iconChannel2");
		iconChannel2Press = atlas.findRegion("iconChannel2Press");
		iconChannel2Disable = atlas.findRegion("iconChannel2Disable");
		iconChannel3 = atlas.findRegion("iconChannel3");
		iconChannel3Press = atlas.findRegion("iconChannel3Press");
		iconChannel3Disable = atlas.findRegion("iconChannel3Disable");
		iconChannel4 = atlas.findRegion("iconChannel4");
		iconChannel4Press = atlas.findRegion("iconChannel4Press");
		iconChannel4Disable = atlas.findRegion("iconChannel4Disable");
		iconChannel5 = atlas.findRegion("iconChannel5");
		iconChannel5Press = atlas.findRegion("iconChannel5Press");
		iconChannel5Disable = atlas.findRegion("iconChannel5Disable");

		highLight = atlas.findRegion("highLight");
		gift1 = atlas.findRegion("gift1");
		gift234 = atlas.findRegion("gift234");
		gift5 = atlas.findRegion("gift5");
		gift1Disable = atlas.findRegion("gift1Disable");
		gift234Disable = atlas.findRegion("gift234Disable");
		gift5Disable = atlas.findRegion("gift5Disable");
		goldGift = atlas.findRegion("goldGift");
		goldGiftDisable = atlas.findRegion("goldGiftDisable");
		iconReceiveGift = atlas.findRegion("iconReceiveGift");
		iconReceiveGiftPress = atlas.findRegion("iconReceiveGiftPress");
		bgGift = atlas.findRegion("bgGiftInit");
		iconDeco = atlas.findRegion("iconDeco");
		xitoLogo = atlas.findRegion("xitoLogo");
		iconRepair = atlas.findRegion("iconRepair");
		iconCuComming = atlas.findRegion("iconCuComming");
		Gdx.app.log(tag, "DA FINISH ");
	}

	// board = atlas.findRegion("BG1")
	public void loadTexture() {
		skin = new Skin(Gdx.files.internal("skin/uiskin.json"));

		manager.load("portal/pack", TextureAtlas.class);

	}

	public void scaleActor(Actor actor) {
		// actor.scaleX = actor.scaleY = MyPoker.game.scale;
		if (actor instanceof GsnImageButton)
			((GsnImageButton) actor).setScale(MyPoker.game.scale);
		else {
			actor.width = actor.width * MyPoker.game.scale;
			actor.height = actor.height * MyPoker.game.scale;
		}
	}

}
